// ---------------------------------------------------
// Photo Album With Click Zoom Effect
// Design theme: Image Gallery (December 13, 2014)
// Modification by. Devy Indriyani
// Input: JavaScript-jQuery
// Sumber URL: http://sahabatblogger77.blogspot.com
//---------------------------------------------------- 

$(function(){
var zIndex= 1, endTop=0, endLeft=365;
function randRotation(el){
var rot = Math.round( Math.random() * 0-0);
return $(el).css({
        '-webkit-transform':'rotate('+rot+'deg)',
        '-moz-transform':'rotate('+rot+'deg)',
        'transform':'rotate('+rot+'deg)'
    });
}

$('.album-sb77 li').each(function(){
randRotation(this).css({
top:Math.round(Math.random()*0-0)
,left:Math.round(Math.random()*0-0)
,'zIndex': zIndex++})
 .click(function(){
 var myZindex = $(this).css('zIndex');
$('.album-sb77 li').not(this).each(function(){
if( $(this).css('zIndex') > myZindex ){
 $(this).css('zIndex',$(this).css('zIndex')-1);
 }
   });
 if(! $(this).is('.active')){
 $(this).toggleClass('active')
 .animate({top:endTop,left:endLeft})
.css({zIndex:$('.album-sb77 li').length });
var activated=$('.album-sb77 .active').not(this);
activated.length && activated.click();
  }else{
 $('.album-sb77 li').each(function(){$(this)
        .css('zIndex',parseInt($(this).css('zIndex'),10)+1)});
 randRotation($(this).toggleClass('active'))
.animate({
   top:Math.round(Math.random()*0-0),
   left:Math.round(Math.random()*0-0)
}).css({zIndex:1});}
    });
   });
});